package com.nmsl.system.exam_project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nmsl.common.annotation.Log;
import com.nmsl.common.core.controller.BaseController;
import com.nmsl.common.core.domain.AjaxResult;
import com.nmsl.common.enums.BusinessType;
import com.nmsl.system.exam_project.domain.ExaminationProject;
import com.nmsl.system.exam_project.service.IExaminationProjectService;
import com.nmsl.common.utils.poi.ExcelUtil;
import com.nmsl.common.core.page.TableDataInfo;

/**
 * 检查项目Controller
 * 
 * @author gmh
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/system/exam_project")
public class ExaminationProjectController extends BaseController
{
    @Autowired
    private IExaminationProjectService examinationProjectService;

    /**
     * 查询检查项目列表
     */
    @PreAuthorize("@ss.hasPermi('system:exam_project:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExaminationProject examinationProject)
    {
        startPage();
        List<ExaminationProject> list = examinationProjectService.selectExaminationProjectList(examinationProject);
        return getDataTable(list);
    }

    /**
     * 导出检查项目列表
     */
    @PreAuthorize("@ss.hasPermi('system:exam_project:export')")
    @Log(title = "检查项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExaminationProject examinationProject)
    {
        List<ExaminationProject> list = examinationProjectService.selectExaminationProjectList(examinationProject);
        ExcelUtil<ExaminationProject> util = new ExcelUtil<ExaminationProject>(ExaminationProject.class);
        util.exportExcel(response, list, "检查项目数据");
    }

    /**
     * 获取检查项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:exam_project:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(examinationProjectService.selectExaminationProjectById(id));
    }

    /**
     * 新增检查项目
     */
    @PreAuthorize("@ss.hasPermi('system:exam_project:add')")
    @Log(title = "检查项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExaminationProject examinationProject)
    {
        return toAjax(examinationProjectService.insertExaminationProject(examinationProject));
    }

    /**
     * 修改检查项目
     */
    @PreAuthorize("@ss.hasPermi('system:exam_project:edit')")
    @Log(title = "检查项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExaminationProject examinationProject)
    {
        return toAjax(examinationProjectService.updateExaminationProject(examinationProject));
    }

    /**
     * 删除检查项目
     */
    @PreAuthorize("@ss.hasPermi('system:exam_project:remove')")
    @Log(title = "检查项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(examinationProjectService.deleteExaminationProjectByIds(ids));
    }
}
